// 引入 request 方法，假设 request 方法已经定义在某个工具文件中
import request from '/@/utils/request';
import {
    AddJobDetailInput,
    AddJobTriggerInput,
    DeleteJobDetailInput,
    DeleteJobTriggerInput,
    JobDetailInput,
    JobTriggerInput,
    PageJobDetailInput,
    PageJobTriggerRecordInput,
    UpdateJobDetailInput,
    UpdateJobTriggerInput,
} from '../models';
// 定义 API 路径枚举
enum Api {
    AddJobDetail = '/sysJob/addJobDetail',
    AddJobTrigger = '/sysJob/addJobTrigger',
    CancelJob = '/sysJob/cancelJob',
    CancelSleep = '/sysJob/cancelSleep',
    DeleteJobDetail = '/sysJob/deleteJobDetail',
    DeleteJobTrigger = '/sysJob/deleteJobTrigger',
    JobClusterList = '/sysJob/jobClusterList',
    JobTriggerList = '/sysJob/jobTriggerList',
    ListJobGroup = '/sysJob/listJobGroup',
    PageJobDetail = '/sysJob/pageJobDetail',
    PageJobTriggerRecord = '/sysJob/pageJobTriggerRecord',
    PauseAllJob = '/sysJob/pauseAllJob',
    PauseJob = '/sysJob/pauseJob',
    PauseTrigger = '/sysJob/pauseTrigger',
    PersistAll = '/sysJob/persistAll',
    RunJob = '/sysJob/runJob',
    StartAllJob = '/sysJob/startAllJob',
    StartJob = '/sysJob/startJob',
    StartTrigger = '/sysJob/startTrigger',
    UpdateJobDetail = '/sysJob/updateJobDetail',
    UpdateJobTrigger = '/sysJob/updateJobTrigger',
}

// 添加作业
export const apiSysJobAddJobDetailPost = (body: AddJobDetailInput) =>
    request({
        url: Api.AddJobDetail,
        method: 'post',
        data: body,
    });

// 添加触发器
export const apiSysJobAddJobTriggerPost = (body: AddJobTriggerInput) =>
    request({
        url: Api.AddJobTrigger,
        method: 'post',
        data: body,
    });

// 取消作业
export const apiSysJobCancelJobPost = (body: JobDetailInput) =>
    request({
        url: Api.CancelJob,
        method: 'post',
        data: body,
    });

// 强制唤醒作业调度器
export const apiSysJobCancelSleepPost = () =>
    request({
        url: Api.CancelSleep,
        method: 'post',
    });

// 删除作业
export const apiSysJobDeleteJobDetailPost = (body: DeleteJobDetailInput) =>
    request({
        url: Api.DeleteJobDetail,
        method: 'post',
        data: body,
    });

// 删除触发器
export const apiSysJobDeleteJobTriggerPost = (body: DeleteJobTriggerInput) =>
    request({
        url: Api.DeleteJobTrigger,
        method: 'post',
        data: body,
    });

// 获取集群列表
export const apiSysJobJobClusterListGet = () =>
    request({
        url: Api.JobClusterList,
        method: 'get',
    });

// 获取触发器列表
export const apiSysJobJobTriggerListGet = (jobId?: string) =>
    request({
        url: Api.JobTriggerList,
        method: 'get',
        params: { JobId: jobId },
    });

// 获取作业组名称集合
export const apiSysJobListJobGroupPost = () =>
    request({
        url: Api.ListJobGroup,
        method: 'post',
    });

// 获取作业分页列表
export const apiSysJobPageJobDetailPost = (body: PageJobDetailInput) =>
    request({
        url: Api.PageJobDetail,
        method: 'post',
        data: body,
    });

// 获取作业触发器运行记录分页列表
export const apiSysJobPageJobTriggerRecordPost = (body: PageJobTriggerRecordInput) =>
    request({
        url: Api.PageJobTriggerRecord,
        method: 'post',
        data: body,
    });

// 暂停所有作业
export const apiSysJobPauseAllJobPost = () =>
    request({
        url: Api.PauseAllJob,
        method: 'post',
    });

// 暂停作业
export const apiSysJobPauseJobPost = (body: JobDetailInput) =>
    request({
        url: Api.PauseJob,
        method: 'post',
        data: body,
    });

// 暂停触发器
export const apiSysJobPauseTriggerPost = (body: JobTriggerInput) =>
    request({
        url: Api.PauseTrigger,
        method: 'post',
        data: body,
    });

// 强制触发所有作业持久化
export const apiSysJobPersistAllPost = () =>
    request({
        url: Api.PersistAll,
        method: 'post',
    });

// 执行作业
export const apiSysJobRunJobPost = (body: JobDetailInput) =>
    request({
        url: Api.RunJob,
        method: 'post',
        data: body,
    });

// 启动所有作业
export const apiSysJobStartAllJobPost = () =>
    request({
        url: Api.StartAllJob,
        method: 'post',
    });

// 启动作业
export const apiSysJobStartJobPost = (body: JobDetailInput) =>
    request({
        url: Api.StartJob,
        method: 'post',
        data: body,
    });

// 启动触发器
export const apiSysJobStartTriggerPost = (body: JobTriggerInput) =>
    request({
        url: Api.StartTrigger,
        method: 'post',
        data: body,
    });

// 更新作业
export const apiSysJobUpdateJobDetailPost = (body: UpdateJobDetailInput) =>
    request({
        url: Api.UpdateJobDetail,
        method: 'post',
        data: body,
    });

// 更新触发器
export const apiSysJobUpdateJobTriggerPost = (body: UpdateJobTriggerInput) =>
    request({
        url: Api.UpdateJobTrigger,
        method: 'post',
        data: body,
    });